// Have include guard.
#ifndef ASYNCRESULT_H
#define ASYNCRESULT_H

// Include files.
#include "AsyncStatus.hpp"

/**
 *  The AsyncResult class is used for asynchronous operations.
 *  
 *  This class is untested.
 */
template<typename Result>
class AsyncResult :
	public AsyncStatus
{
	public:
		/**
		 *  Constructor for AsyncResult.
		 */
		AsyncResult()
		{
		}
		
		/**
		 *  Gets the result value.
		 *  
		 *  @returns The result value.
		 */
		virtual Result GetResult() const = 0;
		
		/**
		 *  Trys to get the result value.
		 *  
		 *  @param result A reference to where the output result value will be stored.
		 *  @returns If the async operation as finished.
		 */
		bool TryGetResult(Result &result) const
		{
			if (GetIsFinished())
			{
				result = GetResult();
				return true;
			}
			else
				return false;
		}
};

#endif // #ifndef ASYNCRESULT_H 
